"""
字符串使用
"""
# # 格式化
# a = 153
# b = 12345678.1239567
# s = 'I love python!'
# print('a = %05d' % a)
# print('b = %8.3f' % b)
# print('%17s' % s)
# print('%-17.6s' % s)
#
# #format()
# name = "王晨"
# age = 18
# sex = '男'
# introduce = "我的名字叫{},我今年{}岁啦，我的性别是{}"
# introduce_01 = "我的名字叫{2},我今年{0}岁啦，我的性别是{1}"
# print(introduce.format(name,age,sex))
# print(introduce_01.format(name,age,sex))
#
# #find()
# str1 = "我在上课，班级是24计算机z3，有人睡觉，有人聊天，我很不开心！！"
# str2 = "睡觉"
# print(str1.find(str2))
# print(str1.find("吃饭"))  # 没查到，返回-1
# if str1.find(str2) == -1:
#     print("没有查到。。。")
# else:
#     print("'{}'包含字符串：'{}',它的位置在：'{}'".format(str1,str2,str1.find(str2)))
#
# # split()
# str3 = "hello world !!!"
# print(str3.split())
# print(str3.split(" ",1))
# print(str3.split("-"))
#
# # join()
# # print("-".join(str3))
#
# # "Rain falls   on field  and        tree."
# str4 = "Rain falls   on field  and        tree."
# mid = str4.split()
# print(mid)
# res = " ".join(mid)
# print(res)

# replace()
str5 = "abc def abc efg abc"
print(str5.replace("abc","123"))
print(str5.replace("abc","123",2))
print(str5.replace(" ",""))
#
# # strip()
# print(str5.strip("abc"))
# str6 = "    aaaaaaaaaaaa      bvdgas cccccaaa   "
# print(str6)
# print(str6.strip())
# print(str6.strip(" ac"))

# 转换大小写
# str7 = "gesahgdfsa--HERRHGDGS"
# print(str7.lower())
# print(str7.upper())

# 检测字符串
# str8 = "gradgaDFEq1543"
# str9 = "ghreh5464[]/*-+"
# print(str8.isalnum())
# print(str9.isalnum())